package com.ddw.meedeeuh.shared.movie;

import java.util.regex.Pattern;

class MovieSettingsImpl implements MovieSettings {

	private final MovieNfoConstants nfoConstants;
	private final MovieExportNodes exportNodes;
	private final String libraryPath;
	private final Pattern nameRegex;
	private final Pattern yearRegex;
	private final boolean matchNameOnParentFolder;
	private final boolean matchYearOnParentFolder;
	private final boolean parentFolderNameMustMatchMovie;
	private final boolean matchNameOnNfo;
	private final String tmdbApiKey;
	private final String[] movieExtensions;
	private final String[] ignoreStrings;
	private final boolean usePoster;
	private final boolean useFanart;
	private final boolean useExtraThumbs;
	private final String posterName;
	private final String fanartName;
	private final String extraThumbsFolderName;
	private final Pattern extraThumbsPattern;
	private final String extraThumbsFormat;
	private boolean prettyFormatNfos;
	private boolean addEmptyNfoNodes;

	public MovieSettingsImpl(String libraryPath, Pattern nameRegex, Pattern yearRegex,
			boolean matchNameOnParentFolder, boolean matchYearOnParentFolder, boolean parentFolderNameMustMatchMovie,
			boolean matchNameOnNfo, String tmdbApiKey, String[] movieExtensions, String[] ignoreStrings,
			boolean usePosters, boolean useFanart, boolean useExtraThumbs, String posterName, String fanartName,
			String extraThumbsFolderName, Pattern extraThumbsPattern, String extraThumbsFormat,
			MovieNfoConstants nfoConstants, boolean prettyFormatNfos, boolean addEmptyNfoNodes,
			MovieExportNodes exportNodes) {
		if(nameRegex == null) {
			throw new IllegalArgumentException("The name regex parameter cannot be null");
		}
		if(yearRegex == null) {
			throw new IllegalArgumentException("The year regex parameter cannot be null");
		}
		if(movieExtensions == null || movieExtensions.length == 0) {
			throw new IllegalArgumentException("The movie extensions parameter cannot be null or empty");
		}
		if(ignoreStrings == null) {
			throw new IllegalArgumentException("The ignore strings parameter cannot be null");
		}
		if(usePosters && posterName == null) {
			throw new IllegalArgumentException("The poster name parameter cannot be null when using posters");
		}
		if(useFanart && fanartName == null) {
			throw new IllegalArgumentException("The fanart name parameter cannot be null when using fanart");
		}
		if(useExtraThumbs && extraThumbsFolderName == null) {
			throw new IllegalArgumentException("The extra thumbs folder name parameter cannot be null when using extra thumbs");
		}
		if(useExtraThumbs && extraThumbsPattern == null) {
			throw new IllegalArgumentException("The extra thumbs pattern parameter cannot be null when using extra thumbs");
		}
		if(useExtraThumbs && extraThumbsFormat == null) {
			throw new IllegalArgumentException("The extra thumbs format parameter cannot be null when using extra thumbs");
		}
		if(nfoConstants == null) {
			throw new IllegalArgumentException("The nfo constants parameter cannot be null");
		}
		if(exportNodes == null) {
			throw new IllegalArgumentException("The export nodes parameter cannot be null");
		}

		this.libraryPath = libraryPath;
		this.nameRegex = nameRegex;
		this.yearRegex = yearRegex;
		this.matchNameOnParentFolder = matchNameOnParentFolder;
		this.matchYearOnParentFolder = matchYearOnParentFolder;
		this.parentFolderNameMustMatchMovie = parentFolderNameMustMatchMovie;
		this.matchNameOnNfo = matchNameOnNfo;
		this.tmdbApiKey = tmdbApiKey;
		this.movieExtensions = movieExtensions;
		this.ignoreStrings = ignoreStrings;
		this.useExtraThumbs = useExtraThumbs;
		this.useFanart = useFanart;
		this.usePoster = usePosters;
		this.posterName = posterName;
		this.fanartName = fanartName;
		this.extraThumbsFolderName = extraThumbsFolderName;
		this.extraThumbsFormat = extraThumbsFormat;
		this.extraThumbsPattern = extraThumbsPattern;
		this.nfoConstants = nfoConstants;
		this.prettyFormatNfos = prettyFormatNfos;
		this.addEmptyNfoNodes = addEmptyNfoNodes;
		this.exportNodes = exportNodes;
	}

	@Override
	public String getLibraryPath() {
		return this.libraryPath;
	}

	@Override
	public Pattern getNameRegex() {
		return this.nameRegex;
	}

	@Override
	public Pattern getYearRegex() {
		return this.yearRegex;
	}

	@Override
	public boolean matchNameOnParentFolder() {
		return this.matchNameOnParentFolder;
	}

	@Override
	public boolean matchYearOnParentFolder() {
		return this.matchYearOnParentFolder;
	}

	@Override
	public String getTmdbApiKey() {
		return this.tmdbApiKey;
	}

	@Override
	public String[] getMovieExtensions() {
		return this.movieExtensions;
	}

	@Override
	public boolean parentFolderNameMustMatchMovie() {
		return this.parentFolderNameMustMatchMovie;
	}

	@Override
	public String[] getIgnoreStrings() {
		return this.ignoreStrings;
	}

	@Override
	public boolean matchNameOnNfo() {
		return this.matchNameOnNfo;
	}

	@Override
	public boolean usePosters() {
		return this.usePoster;
	}

	@Override
	public boolean useFanart() {
		return this.useFanart;
	}

	@Override
	public boolean useExtraThumbs() {
		return this.useExtraThumbs;
	}

	@Override
	public String getPosterName() {
		return this.posterName;
	}

	@Override
	public String getFanartName() {
		return this.fanartName;
	}

	@Override
	public String getExtraThumbsFolderName() {
		return this.extraThumbsFolderName;
	}

	@Override
	public Pattern getExtraThumbsPattern() {
		return this.extraThumbsPattern;
	}

	@Override
	public String getExtraThumbsFormat() {
		return this.extraThumbsFormat;
	}

	@Override
	public MovieNfoConstants getNfoConstants() {
		return this.nfoConstants;
	}

	@Override
	public boolean getPrettyFormatNfo() {
		return this.prettyFormatNfos;
	}

	@Override
	public void setPrettyFormatNfo(boolean prettyFormat) {
		this.prettyFormatNfos = prettyFormat;
	}

	@Override
	public boolean getAddEmptyNfoNodes() {
		return this.addEmptyNfoNodes;
	}

	@Override
	public void setAddEmptyNfoNodes(boolean addEmptyNfoNodes) {
		this.addEmptyNfoNodes = addEmptyNfoNodes;
	}

	@Override
	public MovieExportNodes getExportNodes() {
		return this.exportNodes;
	}

}
